﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using Gmantis.Controls.Automation;

namespace Gmantis.Controls.Extended
{
    public enum ColorPickerMode
    {
        Basic,
        Advanced,
        Both
    }

    [TemplatePart(Name = "AdvancedTab", Type = typeof(TabItem)), 
    TemplatePart(Name = "Advanced", Type = typeof(AdvancedColorPickerPart)), 
    TemplateVisualState(Name = "MouseOver", GroupName = "CommonStates"), 
    TemplateVisualState(Name = "Focused", GroupName = "FocusStates"), 
    TemplatePart(Name = "DropDown", Type = typeof(DropDownButton)), 
    TemplatePart(Name = "BasicTab", Type = typeof(TabItem)), 
    TemplatePart(Name = "Tabs", Type = typeof(TabControl)), 
    TemplatePart(Name = "Basic", Type = typeof(BasicColorPickerPart)), 
    TemplateVisualState(Name = "Disabled", GroupName = "CommonStates"), 
    TemplateVisualState(Name = "Normal", GroupName = "CommonStates"), 
    TemplateVisualState(Name = "InvalidFocused", GroupName = "ValidationStatesStates"), 
    TemplateVisualState(Name = "InvalidUnfocused", GroupName = "ValidationStatesStates"), 
    TemplateVisualState(Name = "Valid", GroupName = "ValidationStatesStates"), 
    TemplateVisualState(Name = "Unfocused", GroupName = "FocusStates"), 
    StyleTypedProperty(Property = "ColorContainerStyle", StyleTargetType = typeof(ItemsControl)), 
    StyleTypedProperty(Property = "ValidationDecoratorStyle", StyleTargetType = typeof(ValidationDecorator))]
    public class ColorPicker : Control
    {
        // Fields
        internal AdvancedColorPickerPart _elementAdvanced;
        internal TabItem _elementAdvancedTab;
        internal BasicColorPickerPart _elementBasic;
        internal TabItem _elementBasicTab;
        internal DropDownButton _elementDropDown;
        internal TabControl _elementTabs;
        internal bool _isLoaded;
        private AutomationPeer _peer;
        private bool _throwIsDropDownOpenChanged;
        private bool _throwIsMouseOverChanged;
        private bool _throwSelectedColorChanged;
        internal const string AdvancedElementName = "Advanced";
        internal const string AdvancedTabElementName = "AdvancedTab";
        internal const string BasicElementName = "Basic";
        internal const string BasicTabElementName = "BasicTab";
        private IValueConverter brushConverter;
        public static readonly DependencyProperty ColorContainerStyleProperty = DependencyProperty.Register("ColorContainerStyle", typeof(Style), typeof(ColorPicker), null);
        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ColorPicker), null);
        public static readonly DependencyProperty DropDownDirectionProperty = DependencyProperty.Register("DropDownDirection", typeof(DropDownDirection), typeof(ColorPicker), new PropertyMetadata(DropDownDirection.BelowOrAbove));
        internal const string DropDownElementName = "DropDown";
        public static readonly DependencyProperty DropDownHeaderProperty = DependencyProperty.Register("DropDownHeader", typeof(UIElement), typeof(ColorPicker), null);
        public static readonly DependencyProperty FocusBrushProperty = DependencyProperty.Register("FocusBrush", typeof(Brush), typeof(ColorPicker), null);
        internal static readonly DependencyProperty ForceMouseOverProperty = DependencyProperty.Register("ForceMouseOver", typeof(bool), typeof(ColorPicker), new PropertyMetadata(new PropertyChangedCallback(ColorPicker.OnForceMouseOverPropertyChanged)));
        public static readonly DependencyProperty InputBackgroundProperty = DependencyProperty.Register("InputBackground", typeof(Brush), typeof(ColorPicker), null);
        public static readonly DependencyProperty InputForegroundProperty = DependencyProperty.Register("InputForeground", typeof(Brush), typeof(ColorPicker), null);
        public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register("IsDropDownOpen", typeof(bool), typeof(ColorPicker), new PropertyMetadata(false, new PropertyChangedCallback(ColorPicker.OnIsDropDownOpenPropertyChanged)));
        public static readonly DependencyProperty IsFocusedProperty = DependencyProperty.Register("IsFocused", typeof(bool), typeof(ColorPicker), new PropertyMetadata(new PropertyChangedCallback(ColorPicker.OnIsFocusedPropertyChanged)));
        public static readonly DependencyProperty IsMouseOverProperty = DependencyProperty.Register("IsMouseOver", typeof(bool), typeof(ColorPicker), new PropertyMetadata(new PropertyChangedCallback(ColorPicker.OnIsMouseOverPropertyChanged)));
        public static readonly DependencyProperty ModeProperty = DependencyProperty.Register("Mode", typeof(ColorPickerMode), typeof(ColorPicker), new PropertyMetadata(new PropertyChangedCallback(ColorPicker.OnModePropertyChanged)));
        public static readonly DependencyProperty MouseOverBrushProperty = DependencyProperty.Register("MouseOverBrush", typeof(Brush), typeof(ColorPicker), null);
        public static readonly DependencyProperty PaletteProperty = DependencyProperty.Register("Palette", typeof(ColorPalette), typeof(ColorPicker), new PropertyMetadata(ColorPalette.GetColorPalette(Office2007ColorTheme.Office)));
        public static readonly DependencyProperty PressedBrushProperty = DependencyProperty.Register("PressedBrush", typeof(Brush), typeof(ColorPicker), null);
        public static readonly DependencyProperty SelectedBrushProperty = DependencyProperty.Register("SelectedBrush", typeof(Brush), typeof(ColorPicker), new PropertyMetadata(new SolidColorBrush(Colors.Black), new PropertyChangedCallback(ColorPicker.OnSelectedBrushPropertyChanged)));
        public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorPicker), new PropertyMetadata(Colors.Black, new PropertyChangedCallback(ColorPicker.OnSelectedColorPropertyChanged)));
        public static readonly DependencyProperty ShowAlphaChannelProperty = DependencyProperty.Register("ShowAlphaChannel", typeof(bool), typeof(ColorPicker), new PropertyMetadata(true));
        public static readonly DependencyProperty ShowRecentColorsProperty = DependencyProperty.Register("ShowRecentColors", typeof(bool), typeof(ColorPicker), new PropertyMetadata(true));
        public static readonly DependencyProperty ShowTransparentColorProperty = DependencyProperty.Register("ShowTransparentColor", typeof(bool), typeof(ColorPicker), null);
        internal const string TabsElementName = "Tabs";
        public static readonly DependencyProperty ValidationDecoratorStyleProperty = DependencyProperty.Register("ValidationDecoratorStyle", typeof(Style), typeof(ColorPicker), null);

        // Events
        public event EventHandler<PropertyChangedEventArgs<bool>> IsDropDownOpenChanged;
        public event EventHandler<PropertyChangedEventArgs<bool>> IsMouseOverChanged;
        public event EventHandler<PropertyChangedEventArgs<Color>> SelectedColorChanged;

        // Methods
        public ColorPicker()
        {
            RoutedEventHandler handler = null;
            DependencyPropertyChangedEventHandler handler2 = null;
            this._throwSelectedColorChanged = true;
            this._throwIsDropDownOpenChanged = true;
            this._throwIsMouseOverChanged = true;
            base.DefaultStyleKey = typeof(ColorPicker);
            if (handler == null)
            {
                handler = delegate(object param0, RoutedEventArgs param1)
                {
                    this.ChangeVisualStateCommon(false);
                    this.ChangeVisualStateFocus(false);
                };
            }
            base.Loaded += handler;
            if (handler2 == null)
            {
                handler2 = (s, a) => this.ChangeVisualStateCommon(true);
            }
            base.IsEnabledChanged += handler2;
            base.GotFocus += new RoutedEventHandler(this.Control_GotFocus);
            base.LostFocus += new RoutedEventHandler(this.Control_LostFocus);
            base.MouseEnter += new MouseEventHandler(this.Control_MouseEnter);
            base.MouseLeave += new MouseEventHandler(this.Control_MouseLeave);
            this.SetCustomDefaultValues();
        }

        private void Control_GotFocus(object sender, RoutedEventArgs e)
        {
            this.IsFocused = true;
        }

        private void Control_LostFocus(object sender, RoutedEventArgs e)
        {
            this.IsFocused = false;
        }

        private void Control_MouseEnter(object sender, MouseEventArgs e)
        {
            if (InputEventArgs.GetPointerType(e) == PointerDeviceType.Mouse)
            {
                this.IsMouseOver = true;
            }
        }

        private void Control_MouseLeave(object sender, MouseEventArgs e)
        {
            if (InputEventArgs.GetPointerType(e) == PointerDeviceType.Mouse)
            {
                this.IsMouseOver = false;
            }
        }

        protected void ChangeVisualStateCommon(bool useTransitions)
        {
            if (!base.IsEnabled)
            {
                VisualStateHelper.GoToState(this, "Disabled", useTransitions);
            }
            if (base.IsEnabled)
            {
                VisualStateHelper.GoToState(this, "MouseOver", useTransitions);
            }
            if ((base.IsEnabled && !this.IsMouseOver) && !this.ForceMouseOver)
            {
                VisualStateHelper.GoToState(this, "Normal", useTransitions);
            }
        }

        protected void ChangeVisualStateFocus(bool useTransitions)
        {
            if (!this.IsFocused)
            {
                VisualStateHelper.GoToState(this, "Unfocused", useTransitions);
            }
            if (this.IsFocused)
            {
                VisualStateHelper.GoToState(this, "Focused", useTransitions);
            }
        }

        private T GetTemplateChild<T>(string childName, bool required, ref string errors) where T : class
        {
            DependencyObject templateChild = base.GetTemplateChild(childName);
            ApplyTemplateHelper.VerifyTemplateChild(typeof(T), "template part", childName, templateChild, required, ref errors);
            return (templateChild as T);
        }

        private static Storyboard GetTemplateChildResource(FrameworkElement root, string resourceName, bool required, ref string errors)
        {
            return GetTemplateChildResource<Storyboard>(root, resourceName, required, ref errors);
        }

        private static T GetTemplateChildResource<T>(FrameworkElement root, string resourceName, bool required, ref string errors) where T : class
        {
            object child = root.Resources[resourceName];
            ApplyTemplateHelper.VerifyTemplateChild(typeof(T), "resource", resourceName, child, required, ref errors);
            return (child as T);
        }

        private void Handle_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if ((e.Key == Key.Escape) && (this._elementDropDown != null))
            {
                this.IsDropDownOpen = false;
                e.Handled = true;
                base.Focus();
            }
        }

        private void InitializeAdvancedPart()
        {
            this._elementAdvanced.Loaded += (s, e) => this._elementAdvanced.Focus();
            Binding binding = new Binding
            {
                Mode = BindingMode.TwoWay
            };
            this._elementAdvanced.SetBinding(AdvancedColorPickerPart.SelectedColorProperty, binding.From<ColorPicker>(this, x => x.SelectedColor));
            this._elementAdvanced.ColorPicked += delegate(object s, EventArgs e)
            {
                if (this._elementDropDown != null)
                {
                    this._elementDropDown.IsDropDownOpen = false;
                    base.Focus();
                }
            };
            this._elementAdvanced.SetBinding(AdvancedColorPickerPart.ShowAlphaChannelProperty, new Binding().From<ColorPicker>(this, x => x.ShowAlphaChannel));
        }

        private void InitializeBasicPart()
        {
            this._elementBasic.Loaded += (s, e) => this._elementBasic.Focus();
            Binding binding = new Binding
            {
                Mode = BindingMode.TwoWay
            };
            this._elementBasic.SetBinding(BasicColorPickerPart.SelectedColorProperty, binding.From<ColorPicker>(this, x => x.SelectedColor));
            this._elementBasic.ColorPicked += delegate(object s, EventArgs e)
            {
                if (this._elementDropDown != null)
                {
                    this._elementDropDown.IsDropDownOpen = false;
                    base.Focus();
                }
            };
            this._elementBasic.SetBinding(BasicColorPickerPart.PaletteProperty, new Binding().From<ColorPicker>(this, x => x.Palette));
            this._elementBasic.SetBinding(BasicColorPickerPart.ShowRecentColorsProperty, new Binding().From<ColorPicker>(this, x => x.ShowRecentColors));
            this._elementBasic.SetBinding(BasicColorPickerPart.ShowTransparentColorProperty, new Binding().From<ColorPicker>(this, x => x.ShowTransparentColor));
        }

        private void OnAfterApplyTemplate()
        {
            EventHandler<PropertyChangedEventArgs<bool>> handler = null;
            if (this._elementDropDown != null)
            {
                this._elementDropDown.KeyDown += new KeyEventHandler(this.Handle_KeyDown);
                this._elementDropDown.IsDropDownOpen = this.IsDropDownOpen;
                if (handler == null)
                {
                    handler = delegate(object s, PropertyChangedEventArgs<bool> e)
                    {
                        this.IsDropDownOpen = this._elementDropDown.IsDropDownOpen;
                        if ((this._elementDropDown.IsDropDownOpen && (this._elementTabs != null)) && ((this._elementBasicTab != null) && (this.Mode == ColorPickerMode.Both)))
                        {
                            this._elementTabs.SelectedItem = this._elementBasicTab;
                        }
                    };
                }
                this._elementDropDown.IsDropDownOpenChanged += handler;
            }
            if (this._elementBasic != null)
            {
                this._elementBasic.KeyDown += new KeyEventHandler(this.Handle_KeyDown);
            }
            if (this._elementAdvanced != null)
            {
                this._elementAdvanced.KeyDown += new KeyEventHandler(this.Handle_KeyDown);
            }
            if (this._elementTabs != null)
            {
                this._elementTabs.ShowSingleTab = false;
            }
            this.UpdateTabs();
        }

        public override void OnApplyTemplate()
        {
            string errors = string.Empty;
            base.OnApplyTemplate();
            this._isLoaded = true;
            this._elementDropDown = this.GetTemplateChild<DropDownButton>("DropDown", true, ref errors);
            this._elementBasicTab = this.GetTemplateChild<TabItem>("BasicTab", false, ref errors);
            this._elementAdvancedTab = this.GetTemplateChild<TabItem>("AdvancedTab", false, ref errors);
            this._elementTabs = this.GetTemplateChild<TabControl>("Tabs", false, ref errors);
            this._elementBasic = this.GetTemplateChild<BasicColorPickerPart>("Basic", false, ref errors);
            if (this._elementBasic != null)
            {
                this.InitializeBasicPart();
            }
            this._elementAdvanced = this.GetTemplateChild<AdvancedColorPickerPart>("Advanced", false, ref errors);
            if (this._elementAdvanced != null)
            {
                this.InitializeAdvancedPart();
            }
            if (!string.IsNullOrEmpty(errors))
            {
                this._isLoaded = false;
                if ((base.Template != null) && !PlatformIndependent.IsInDesignMode(this))
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Template cannot be applied to ColorPicker.\nDetails: {0}", new object[] { errors }));
                }
            }
            else
            {
                this.ChangeVisualStateCommon(false);
                this.ChangeVisualStateFocus(false);
                this.OnAfterApplyTemplate();
            }
        }

        protected override AutomationPeer OnCreateAutomationPeer()
        {
            if (this._peer == null)
            {
                this._peer = AutomationPeerFactory.CreateAutomationPeer(this, typeof(ColorPicker));
            }
            if (this._peer == null)
            {
                return base.OnCreateAutomationPeer();
            }
            return this._peer;
        }

        private static void OnForceMouseOverPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ColorPicker).ChangeVisualStateCommon(true);
        }

        private void OnIsDropDownOpenChanged(bool old)
        {
            if (this._elementDropDown != null)
            {
                this._elementDropDown.IsDropDownOpen = this.IsDropDownOpen;
            }
        }

        private static void OnIsDropDownOpenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPicker sender = d as ColorPicker;
            bool oldValue = (bool)e.OldValue;
            sender.OnIsDropDownOpenChanged(oldValue);
            if ((sender.IsDropDownOpenChanged != null) && sender._throwIsDropDownOpenChanged)
            {
                PropertyChangedEventArgs<bool> args = new PropertyChangedEventArgs<bool>
                {
                    OldValue = (bool)e.OldValue,
                    NewValue = (bool)e.NewValue
                };
                sender.IsDropDownOpenChanged(sender, args);
            }
        }

        private static void OnIsFocusedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ColorPicker).ChangeVisualStateFocus(true);
        }

        private static void OnIsMouseOverPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPicker sender = d as ColorPicker;
            if ((sender.IsMouseOverChanged != null) && sender._throwIsMouseOverChanged)
            {
                PropertyChangedEventArgs<bool> args = new PropertyChangedEventArgs<bool>
                {
                    OldValue = (bool)e.OldValue,
                    NewValue = (bool)e.NewValue
                };
                sender.IsMouseOverChanged(sender, args);
            }
            sender.ChangeVisualStateCommon(true);
        }

        private void OnModeChanged(ColorPickerMode oldValue)
        {
            if (this._isLoaded)
            {
                this.UpdateTabs();
            }
        }

        private static void OnModePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPicker picker = d as ColorPicker;
            ColorPickerMode oldValue = (ColorPickerMode)e.OldValue;
            picker.OnModeChanged(oldValue);
        }

        private void OnSelectedBrushChanged(Brush oldValue)
        {
            try
            {
                Color? nullable = (Color?)this.brushConverter.Convert(this.SelectedBrush, typeof(Color), null, CultureInfo.InvariantCulture);
                if (nullable.HasValue && (this.SelectedColor != nullable))
                {
                    this.SelectedColor = nullable.Value;
                }
            }
            catch
            {
            }
        }

        private static void OnSelectedBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPicker picker = d as ColorPicker;
            Brush oldValue = (Brush)e.OldValue;
            picker.OnSelectedBrushChanged(oldValue);
        }

        private void OnSelectedColorChanged(Color oldValue)
        {
            try
            {
                Brush brush = this.brushConverter.Convert(this.SelectedColor, typeof(Brush), null, CultureInfo.InvariantCulture) as Brush;
                if (this.SelectedBrush != brush)
                {
                    this.SelectedBrush = brush;
                }
            }
            catch
            {
            }
        }

        private static void OnSelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPicker sender = d as ColorPicker;
            Color oldValue = (Color)e.OldValue;
            sender.OnSelectedColorChanged(oldValue);
            if ((sender.SelectedColorChanged != null) && sender._throwSelectedColorChanged)
            {
                PropertyChangedEventArgs<Color> args = new PropertyChangedEventArgs<Color>
                {
                    OldValue = (Color)e.OldValue,
                    NewValue = (Color)e.NewValue
                };
                sender.SelectedColorChanged(sender, args);
            }
        }

        private void SetCustomDefaultValues()
        {
            this.brushConverter = CustomConverter.Create(delegate(object value, Type type, object parameters, CultureInfo culture)
            {
                if (value is Color)
                {
                    return new SolidColorBrush((Color)value);
                }
                if (value is SolidColorBrush)
                {
                    return ((SolidColorBrush)value).Color;
                }
                if (value is GradientBrush)
                {
                    GradientBrush brush = value as GradientBrush;
                    if (brush.GradientStops.Count > 0)
                    {
                        return brush.GradientStops[0].Color;
                    }
                }
                return value;
            });
        }

        private void UpdateTabs()
        {
            if (((this._elementTabs != null) && (this._elementBasicTab != null)) && (this._elementAdvancedTab != null))
            {
                switch (this.Mode)
                {
                    case ColorPickerMode.Basic:
                        if (!this._elementTabs.Items.Contains(this._elementBasicTab))
                        {
                            this._elementTabs.Items.Insert(0, this._elementBasicTab);
                        }
                        this._elementTabs.Items.Remove(this._elementAdvancedTab);
                        this._elementTabs.SelectedItem = this._elementBasicTab;
                        return;

                    case ColorPickerMode.Advanced:
                        this._elementTabs.Items.Remove(this._elementBasicTab);
                        if (!this._elementTabs.Items.Contains(this._elementAdvancedTab))
                        {
                            this._elementTabs.Items.Add(this._elementAdvancedTab);
                        }
                        this._elementTabs.SelectedItem = this._elementAdvancedTab;
                        return;
                }
                if (!this._elementTabs.Items.Contains(this._elementBasicTab))
                {
                    this._elementTabs.Items.Insert(0, this._elementBasicTab);
                }
                if (!this._elementTabs.Items.Contains(this._elementAdvancedTab))
                {
                    this._elementTabs.Items.Add(this._elementAdvancedTab);
                }
                this._elementTabs.SelectedItem = this._elementBasicTab;
            }
        }

        // Properties
        public Style ColorContainerStyle
        {
            get { return (Style)GetValue(ColorContainerStyleProperty); }
            set { SetValue(ColorContainerStyleProperty, value); }
        }

        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }

        public DropDownDirection DropDownDirection
        {
            get { return (DropDownDirection)GetValue(DropDownDirectionProperty); }
            set { SetValue(DropDownDirectionProperty, value); }
        }

        public UIElement DropDownHeader
        {
            get { return (UIElement)GetValue(DropDownHeaderProperty); }
            set { SetValue(DropDownHeaderProperty, value); }
        }

        public Brush FocusBrush
        {
            get { return (Brush)GetValue(FocusBrushProperty); }
            set { SetValue(FocusBrushProperty, value); }
        }

        internal bool ForceMouseOver
        {
            get { return (bool)GetValue(ForceMouseOverProperty); }
            set { SetValue(ForceMouseOverProperty, value); }
        }

        public Brush InputBackground
        {
            get { return (Brush)GetValue(InputBackgroundProperty); }
            set { SetValue(InputBackgroundProperty, value); }
        }

        public Brush InputForeground
        {
            get { return (Brush)GetValue(InputForegroundProperty); }
            set { SetValue(InputForegroundProperty, value); }
        }

        public bool IsDropDownOpen
        {
            get { return (bool)GetValue(IsDropDownOpenProperty); }
            set { SetValue(IsDropDownOpenProperty, value); }
        }

        public bool IsFocused
        {
            get { return (bool)GetValue(IsFocusedProperty); }
            internal set { SetValue(IsFocusedProperty, value); }
        }

        public bool IsMouseOver
        {
            get { return (bool)GetValue(IsMouseOverProperty); }
            set { SetValue(IsMouseOverProperty, value); }
        }

        public ColorPickerMode Mode
        {
            get { return (ColorPickerMode)GetValue(ModeProperty); }
            set { SetValue(ModeProperty, value); }
        }

        public Brush MouseOverBrush
        {
            get { return (Brush)GetValue(MouseOverBrushProperty); }
            set { SetValue(MouseOverBrushProperty, value); }
        }

        public ColorPalette Palette
        {
            get { return (ColorPalette)GetValue(PaletteProperty); }
            set { SetValue(PaletteProperty, value); }
        }

        public Brush PressedBrush
        {
            get { return (Brush)GetValue(PressedBrushProperty); }
            set { SetValue(PressedBrushProperty, value); }
        }

        public Brush SelectedBrush
        {
            get { return (Brush)GetValue(SelectedBrushProperty); }
            set { SetValue(SelectedBrushProperty, value); }
        }

        public Color SelectedColor
        {
            get { return (Color)GetValue(SelectedColorProperty); }
            set { SetValue(SelectedColorProperty, value); }
        }

        public bool ShowAlphaChannel
        {
            get { return (bool)GetValue(ShowAlphaChannelProperty); }
            set { SetValue(ShowAlphaChannelProperty, value); }
        }

        public bool ShowRecentColors
        {
            get { return (bool)GetValue(ShowRecentColorsProperty); }
            set { SetValue(ShowRecentColorsProperty, value); }
        }

        public bool ShowTransparentColor
        {
            get { return (bool)GetValue(ShowTransparentColorProperty); }
            set { SetValue(ShowTransparentColorProperty, value); }
        }

        public Style ValidationDecoratorStyle
        {
            get { return (Style)GetValue(ValidationDecoratorStyleProperty); }
            set { SetValue(ValidationDecoratorStyleProperty, value); }
        }
    }
}
